import {Notice} from 'view-design'

const notice = ({
                  title = '消息提醒',
                  content = '角色信息发生更换,3秒后将更新角色信息,期间将导致页面刷新,请留意',
                  duration = 3,
                  showTimer = false,
                  type = 'info',
                  params = {}
                }) => {
  return new Promise((resolve, reject) => {
    let timer = null;
    let time = 3;
    Notice[type]({
      title: title,
      desc: content,
      duration: duration,
      onClose: () => {
        resolve(params);
      }
    });

    if (showTimer) {
      setTimeout(() => {
        time -= 1;
        if (!timer) {
          clearTimeout(timer);
          resolve()
        }
      },1000);
    }
  })
}

export default notice;
